package tgc.rj.zz.custom;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import tgc.rj.zz.entity.Log;
import tgc.rj.zz.service.LogService;

/*
 * 操作日志工具类
 */
@Controller
public class LogUtils {

	@Autowired
	private LogService service;

	public void log(String username, String name, String op) {
		Log log = new Log();
		log.setUsername(username);
		log.setName(name);
		log.setOperation(op);
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String date = df.format(new Date());
		log.setDate(date);
		service.save(log);
	}
}
